#pragma once

typedef void (*TIMERPROCFUNC)(UINT uTimerID, LPVOID pUserData);

class CTimer
{
	typedef hash_map<UINT, CTimer*> CTimerMap;
private:
	static UINT m_uTimerIDSeed;

	static CWnd m_TimerWnd;
	static CTimerMap m_TimerMap;

	static void CALLBACK TimerServiceProc(HWND hWnd, UINT uMsg, UINT uIDEvent, DWORD dwTime);

	const UINT m_nTimerID;

	TIMERPROCFUNC m_pTimerProc;
	LPVOID m_pUserData;

public:
	CTimer(void);
	~CTimer(void);

	static BOOL StartService();
	static void StopService();

	inline UINT GetTimerID() const{
		return m_nTimerID;
	}

	void SetTimerProc(TIMERPROCFUNC pTimerProc, LPVOID pUserData){
		m_pTimerProc = pTimerProc;
		m_pUserData = pUserData;
	}

	BOOL StartTimer(UINT uElapse);
	BOOL CloseTimer();
};
